--坚城
local jiancheng = fk.CreateSkill {
    name = "mcdh_jiancheng",
    tags= {Skill.Limited}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"


jiancheng:addEffect(fk.DamageCaused,{
     can_trigger = function(self, event, target, player, data)
       if target == player and player:hasSkill(self)  and player:usedSkillTimes(jiancheng.name) == 0  then
            return #player.room.logic:getActualDamageEvents(1, function(e)
        return e.data.from == target or e.data.to == target
      end) == 0
       end
    end,
    on_use=function(self, event, target, player, data)
        local room = player.room
        data:preventDamage()
        if room:getTag("RoundCount") >= 3 then
            data.to:drawCards(2,self.name)
            room:changeMaxHp(data.to,1)
            room:recover({who = data.to, num = 1})
        end
    end
}
)

jiancheng:addEffect(fk.DamageInflicted,{
     can_trigger = function(self, event, target, player, data)
       if target == player and player:hasSkill(self) and  player:usedSkillTimes(jiancheng.name) == 0 then
            return #player.room.logic:getActualDamageEvents(1, function(e)
        return e.data.from == target or e.data.to == target
      end) == 0
       end
    end,
    on_use=function(self, event, target, player, data)
        local room = player.room
        data:preventDamage()
        if room:getTag("RoundCount") >= 3 then
            data.to:drawCards(2,self.name)
            room:changeMaxHp(data.to,1)
            room:recover({who = data.to, num = 1})
        end
    end
})

Fk:loadTranslationTable{
    ["mcdh_jiancheng"] = "坚城",
    [":mcdh_jiancheng"] ="限定技，当你每回合首次造成或受到伤害时，你可以防止之，然后若本轮轮数不小于3，防止受到伤害的角色摸两张牌，增加1点体力上限并回复1点体力。",
}

return jiancheng